<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use Hyperf\Di\Annotation\Inject;
use Hyperf\Utils\ApplicationContext;
use App\JsonRpc\CalculatorServiceInterface;

class IndexController extends AbstractController
{
    /**
     * @Inject()
     * @var CalculatorServiceInterface
     */
    private $calculatorService;
    public function index()
    {
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();

        $client = ApplicationContext::getContainer()->get(CalculatorServiceInterface::class);
        $result = $client->add(1, 2);

        var_dump($result);
        return [
            'cal' => $result,
            'cal2' => $this->calculatorService->add(3,5),
            'method' => $method,
            'message' => "Hello {$user}.",
        ];
    }
}
